package com.xzr.hospitalregister.base;


import android.os.SystemClock;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;


/**
 * A simple {@link Fragment} subclass.
 */
public class BaseFragment extends Fragment implements View.OnClickListener, TextWatcher {


    public void initWidget(View view) {

    }

    public void initData() {

    }

    private int oldId = -1;
    private Long lastClickTime;
    public Boolean doubleClick = false;
    @Override
    public void onClick(View v) {
        System.out.println("**************************************************************");
        if (oldId == -1) {
            lastClickTime = SystemClock.elapsedRealtime();
            oldId = v.getId();
            System.out.println("1");
        } else if (v.getId() == oldId) {
            long time = SystemClock.elapsedRealtime();
            if (time - lastClickTime < 1500) {
                doubleClick = true;
                System.out.println("2  time:" + time + "   差值：" + (time - lastClickTime));
            } else {
                doubleClick = false;
                lastClickTime = time;
                oldId = v.getId();
                System.out.println("3  time:" + time + " 大于1500ms ");
            }
        } else if (v.getId() != oldId) {
            doubleClick = false;
            lastClickTime = SystemClock.elapsedRealtime();
            oldId = v.getId();
            System.out.println("4");
        }
        System.out.println("oldId:   " + oldId + "    lastClickTime:   " + lastClickTime + "   v.getId:    " + v.getId());
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {

    }
}
